<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Global - Documentation</title>

    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>

<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
  <div class="navicon"></div>
</label>

<label for="nav-trigger" class="overlay"></label>

<nav>
    <li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading">Classes</li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="BayesianClassifier.html">BayesianClassifier</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="BayesianClassifier.html#score">score</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="BayesianClassifier.html#train">train</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="PerceptronModel.html">PerceptronModel</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="PerceptronModel.html#predict">predict</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="PerceptronModel.html#train">train</a></span></li><li class="nav-heading"><a href="global.html">Globals</a></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#addToMean">addToMean</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#approxEqual">approxEqual</a></span></li><li class="nav-item"><span class="nav-item-type type-member">M</span><span class="nav-item-name"><a href="global.html#bandwidthMethods">bandwidthMethods</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#bernoulliDistribution">bernoulliDistribution</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#binomialDistribution">binomialDistribution</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#bisect">bisect</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#calculateAllDistances">calculateAllDistances</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#calculateCentroids">calculateCentroids</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#calculateChange">calculateChange</a></span></li><li class="nav-item"><span class="nav-item-type type-member">M</span><span class="nav-item-name"><a href="global.html#chiSquaredDistributionTable">chiSquaredDistributionTable</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#chiSquaredGoodnessOfFit">chiSquaredGoodnessOfFit</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#chunk">chunk</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#ckmeans">ckmeans</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#coefficientOfVariation">coefficientOfVariation</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#combinations">combinations</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#combinationsReplacement">combinationsReplacement</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#combineMeans">combineMeans</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#combineVariances">combineVariances</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#createGroups">createGroups</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#cumulativeStdLogisticProbability">cumulativeStdLogisticProbability</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#cumulativeStdNormalProbability">cumulativeStdNormalProbability</a></span></li><li class="nav-item"><span class="nav-item-type type-member">M</span><span class="nav-item-name"><a href="global.html#epsilon">epsilon</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#equalIntervalBreaks">equalIntervalBreaks</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#errorFunction">errorFunction</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#euclideanDistance">euclideanDistance</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#extent">extent</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#extentSorted">extentSorted</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#factorial">factorial</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fillMatrices">fillMatrices</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fillMatrixColumn">fillMatrixColumn</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#gamma">gamma</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#gammaln">gammaln</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#geometricMean">geometricMean</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#harmonicMean">harmonicMean</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#interquartileRange">interquartileRange</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#inverseErrorFunction">inverseErrorFunction</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#jenks">jenks</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#kMeansCluster">kMeansCluster</a></span></li><li class="nav-item"><span class="nav-item-type type-member">M</span><span class="nav-item-name"><a href="global.html#kernelDensityEstimation">kernelDensityEstimation</a></span></li><li class="nav-item"><span class="nav-item-type type-member">M</span><span class="nav-item-name"><a href="global.html#kernels">kernels</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#labelPoints">labelPoints</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#linearRegression">linearRegression</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#linearRegressionLine">linearRegressionLine</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#logAverage">logAverage</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#logit">logit</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#lowerBound">lowerBound</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#makeMatrix">makeMatrix</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#max">max</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#maxSorted">maxSorted</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#mean">mean</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#meanDistanceFromPointToGroup">meanDistanceFromPointToGroup</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#meanDistanceToNearestGroup">meanDistanceToNearestGroup</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#meanSimple">meanSimple</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#median">median</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#medianAbsoluteDeviation">medianAbsoluteDeviation</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#medianSorted">medianSorted</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#min">min</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#minSorted">minSorted</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#mode">mode</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#modeFast">modeFast</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#modeSorted">modeSorted</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#multiQuantileSelect">multiQuantileSelect</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#numericSort">numericSort</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#permutationTest">permutationTest</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#permutationsHeap">permutationsHeap</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#poissonDistribution">poissonDistribution</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#probit">probit</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#product">product</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#quantile">quantile</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#quantileIndex">quantileIndex</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#quantileRank">quantileRank</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#quantileRankSorted">quantileRankSorted</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#quantileSelect">quantileSelect</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#quantileSorted">quantileSorted</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#quickselect">quickselect</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#rSquared">rSquared</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#relativeError">relativeError</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#rootMeanSquare">rootMeanSquare</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sample">sample</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sampleCorrelation">sampleCorrelation</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sampleCovariance">sampleCovariance</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sampleKurtosis">sampleKurtosis</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sampleRankCorrelation">sampleRankCorrelation</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sampleSkewness">sampleSkewness</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sampleStandardDeviation">sampleStandardDeviation</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sampleVariance">sampleVariance</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sampleWithReplacement">sampleWithReplacement</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#shuffle">shuffle</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#shuffleInPlace">shuffleInPlace</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sign">sign</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#silhouette">silhouette</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#silhouetteMetric">silhouetteMetric</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#ssq">ssq</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#standardDeviation">standardDeviation</a></span></li><li class="nav-item"><span class="nav-item-type type-member">M</span><span class="nav-item-name"><a href="global.html#standardNormalTable">standardNormalTable</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#subtractFromMean">subtractFromMean</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sum">sum</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sumNthPowerDeviations">sumNthPowerDeviations</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#sumSimple">sumSimple</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#tTest">tTest</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#tTestTwoSample">tTestTwoSample</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#uniqueCountSorted">uniqueCountSorted</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#upperBound">upperBound</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#variance">variance</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#wilcoxonRankSum">wilcoxonRankSum</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#zScore">zScore</a></span></li>
</nav>

<div id="main">
    
    <h1 class="page-title">Global</h1>
    

    




<section>

<header>
    
        <h2>
        
        </h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        

        


<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>


        
    
    </div>

    

    

    

     

    

    
        <h3 class="subsection-title">Members</h3>

        
            
<div class="section-members">
<h4 class="name" id="bandwidthMethods"><span class="type-signature">(private, constant) </span>bandwidthMethods<span class="type-signature"></span></h4>




<div class="description">
    <p>常用带宽选择方法</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="kernel_density_estimation.js.html">kernel_density_estimation.js</a>, <a href="kernel_density_estimation.js.html#line24">line 24</a>
    </li></ul></dd>
    

    

    

    
</dl>







</div>

        
            
<div class="section-members">
<h4 class="name" id="chiSquaredDistributionTable"><span class="type-signature">(constant) </span>chiSquaredDistributionTable<span class="type-signature"></span></h4>




<div class="description">
    <p><strong>χ2（卡方）分布的百分位点表</strong></p>
<p><a href="http://en.wikipedia.org/wiki/Chi-squared_distribution">χ2（卡方）分布</a> 常用于以下场景：</p>
<ul>
<li>检验观测分布与理论分布的拟合优度；</li>
<li>检验定性数据分类标准的独立性；</li>
<li>从样本标准差估计正态分布总体标准差的置信区间。</li>
</ul>
<p>数据来源于 William W. Hines 和 Douglas C. Montgomery 的《工程与管理科学中的概率与统计》附录1，表III，Wiley（1980）。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="chi_squared_distribution_table.js.html">chi_squared_distribution_table.js</a>, <a href="chi_squared_distribution_table.js.html#line11">line 11</a>
    </li></ul></dd>
    

    

    

    
</dl>







</div>

        
            
<div class="section-members">
<h4 class="name" id="epsilon"><span class="type-signature">(constant) </span>epsilon<span class="type-signature"></span></h4>




<div class="description">
    <p>我们使用 <code>ε</code>（epsilon）作为迭代过程中的停止准则，直到我们达到“足够接近”的程度。Epsilon 是一个非常小的数字：
在 simple-statistics 中，这个数字是 <strong>0.0001</strong>。</p>
<p>这个值被用于像二项分布这样的计算中，在这些计算中，寻找值的过程是<a href="https://en.wikipedia.org/wiki/Iterative_method">迭代的</a>：
它会一直进行，直到达到足够接近的程度。</p>
<p>下面是一个在<a href="https://en.wikipedia.org/wiki/Gradient_descent">梯度下降</a>中使用 epsilon 的例子，
我们试图找到一个函数导数的局部最小值，该导数由 <code>fDerivative</code> 方法给出。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="epsilon.js.html">epsilon.js</a>, <a href="epsilon.js.html#line30">line 30</a>
    </li></ul></dd>
    

    

    

    
</dl>







    <h5>Example</h5>
    
    <pre class="prettyprint"><code>// 通过计算，我们预计局部最小值出现在 x=9/4
var x_old = 0;
// 算法从 x=6 开始
var x_new = 6;
var stepSize = 0.01;

function fDerivative(x) {
  return 4 * Math.pow(x, 3) - 9 * Math.pow(x, 2);
}

// 循环会一直运行，直到前一个值与当前值之间的差异小于 epsilon —— 这是“足够接近”的一个粗略衡量标准
while (Math.abs(x_new - x_old) > ss.epsilon) {
  x_old = x_new;
  x_new = x_old - stepSize * fDerivative(x_old);
}

console.log('局部最小值出现在', x_new);</code></pre>


</div>

        
            
<div class="section-members">
<h4 class="name" id="kernelDensityEstimation"><span class="type-signature"></span>kernelDensityEstimation<span class="type-signature"></span></h4>




<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Kernel_density_estimation">核密度估计</a>是
一种通过样本数据估计潜在概率分布形态的非参数方法</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="kernel_density_estimation.js.html">kernel_density_estimation.js</a>, <a href="kernel_density_estimation.js.html#line40">line 40</a>
    </li></ul></dd>
    

    

    

    
</dl>







</div>

        
            
<div class="section-members">
<h4 class="name" id="kernels"><span class="type-signature">(private, constant) </span>kernels<span class="type-signature"></span></h4>




<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Kernel_(statistics)#Kernel_functions_in_common_use">常用核函数</a></p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="kernel_density_estimation.js.html">kernel_density_estimation.js</a>, <a href="kernel_density_estimation.js.html#line10">line 10</a>
    </li></ul></dd>
    

    

    

    
</dl>







</div>

        
            
<div class="section-members">
<h4 class="name" id="standardNormalTable"><span class="type-signature">(constant) </span>standardNormalTable<span class="type-signature"></span></h4>




<div class="description">
    <p>标准正态分布表，也称为单位正态表或Z表，
是一个数学表，用于表示Φ（phi）的值，这些值是
<a href="https://en.wikipedia.org/wiki/Normal_distribution#Cumulative_distribution_function">累积分布函数</a>
的值。它用于查找统计量在标准正态分布下
低于、高于或介于某些值之间的概率，并由此扩展到任何正态分布。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="standard_normal_table.js.html">standard_normal_table.js</a>, <a href="standard_normal_table.js.html#line25">line 25</a>
    </li></ul></dd>
    

    

    

    
</dl>







</div>

        
    

    
        <h3 class="subsection-title">Methods</h3>

        
            
<div class="section-method">

    

    <h4 class="name" id="addToMean"><span class="type-signature"></span>addToMean<span class="signature">(mean, n, newValue)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>在向列表中添加新值时，不必重新线性计算列表的均值。
可以通过提供当前均值、生成该均值的列表元素数量以及要添加的新值，
使用此函数计算新的均值。</p>
</div>





<dl class="details">

    

    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>2.5.0</li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="add_to_mean.js.html">add_to_mean.js</a>, <a href="add_to_mean.js.html#line15">line 15</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>mean</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>当前均值</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>n</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>列表中元素的数量</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>newValue</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>要添加的新值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>新的均值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>addToMean(14, 5, 53); // => 20.5</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="approxEqual"><span class="type-signature"></span>approxEqual<span class="signature">(actual, expected, tolerance)</span><span class="type-signature"> &rarr; {boolean}</span></h4>

    



<div class="description">
    <p>近似相等。</p>
<p>该函数用于判断两个数值在给定的相对误差范围内是否近似相等。
在统计学和数值分析中，由于浮点数计算的精度限制，直接比较两个数值是否相等可能不适用，
因此通过设定一个容差范围来评估它们的近似相等性。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="approx_equal.js.html">approx_equal.js</a>, <a href="approx_equal.js.html#line16">line 16</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>actual</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>实际值（待测试的数值）。</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>expected</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>预期值（参考数值）。</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>tolerance</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>容差（可接受的相对差异，默认为 epsilon）。</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>boolean</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>如果实际值与预期值之间的相对误差小于或等于容差，则返回 true；否则返回 false。</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="bernoulliDistribution"><span class="type-signature"></span>bernoulliDistribution<span class="signature">(p)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Bernoulli_distribution">伯努利分布</a>
是一个离散概率分布，描述了一个随机变量以成功概率 <code>p</code> 取值为 1，
以失败概率 <code>q</code> = 1 - <code>p</code> 取值为 0 的情况。
它可以用于表示抛硬币实验，其中 &quot;1&quot; 表示 &quot;正面&quot;，&quot;0&quot; 表示 &quot;反面&quot;（或反之亦然）。
它是二项分布的一个特例，其中试验次数 <code>n</code> = 1。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="bernoulli_distribution.js.html">bernoulli_distribution.js</a>, <a href="bernoulli_distribution.js.html#line14">line 14</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>p</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入值，范围在 0 到 1 之间（包含 0 和 1）</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果 <code>p</code> 不在 0 到 1 之间</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;number></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>在该点的伯努利分布值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>bernoulliDistribution(0.3); // => [0.7, 0.3]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="binomialDistribution"><span class="type-signature"></span>binomialDistribution<span class="signature">(trials, probability)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Binomial_distribution">二项分布</a> 是离散概率分布，
表示在 n 次相互独立的成功/失败实验中，成功的次数。这类成功/失败实验也称为
伯努利试验（Bernoulli trial）；当试验次数 <code>trials = 1</code> 时，二项分布退化为
伯努利分布（Bernoulli Distribution）。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="binomial_distribution.js.html">binomial_distribution.js</a>, <a href="binomial_distribution.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>trials</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>试验次数</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>probability</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>成功的概率</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;number></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>输出概率分布</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="bisect"><span class="type-signature"></span>bisect<span class="signature">(func, start, end, maxIterations, errorTolerance)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Bisection_method">二分法</a> 是一种求根方法，
通过反复将区间一分为二来找到函数的根。</p>
<p>该函数返回一个数值近似值。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="bisect.js.html">bisect.js</a>, <a href="bisect.js.html#line18">line 18</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>func</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>function</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入函数</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>start</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>区间起点</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>end</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>区间终点</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>maxIterations</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>最大迭代次数</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>errorTolerance</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>误差容忍度</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>参数 func 必须是一个函数</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>TypeError</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>估计的根值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>bisect(Math.cos,0,4,100,0.003); // => 1.572265625</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="calculateAllDistances"><span class="type-signature">(private) </span>calculateAllDistances<span class="signature">(points)</span><span class="type-signature"> &rarr; {Array.&lt;Array.&lt;number>>}</span></h4>

    



<div class="description">
    <p>创建全量点间距离查找表</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="silhouette.js.html">silhouette.js</a>, <a href="silhouette.js.html#line72">line 72</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>points</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>N维数据点的坐标数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>对称方阵形式的点间距离矩阵（主对角线为零）</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="calculateCentroids"><span class="type-signature">(private) </span>calculateCentroids<span class="signature">(points, labels, numCluster)</span><span class="type-signature"> &rarr; {Array.&lt;Array.&lt;number>>}</span></h4>

    



<div class="description">
    <p>根据数据点标签计算新的聚类中心</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="k_means_cluster.js.html">k_means_cluster.js</a>, <a href="k_means_cluster.js.html#line73">line 73</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>points</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>数据点坐标数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>labels</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>数据点簇标签数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>numCluster</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>聚类总数</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>当存在无关联数据点的聚类中心时抛出异常</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>计算得到的新聚类中心数组</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="calculateChange"><span class="type-signature">(private) </span>calculateChange<span class="signature">(left, right)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>计算新旧聚类中心的总变化量</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="k_means_cluster.js.html">k_means_cluster.js</a>, <a href="k_means_cluster.js.html#line113">line 113</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>left</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>新聚类中心数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>right</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>旧聚类中心数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>聚类中心坐标变化总和</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="chiSquaredGoodnessOfFit"><span class="type-signature"></span>chiSquaredGoodnessOfFit<span class="signature">(data, distributionType, significance)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Goodness_of_fit#Pearson.27s_chi-squared_test">χ2 (卡方) 拟合优度检验</a>
使用一个拟合优度的度量，该度量是观测频率与期望频率之间差异的平方和，
并除以期望的观测数。由此产生的 χ2 统计量 <code>chiSquared</code> 可以与卡方分布进行比较，
以确定拟合优度。为了确定卡方分布的自由度，取观测频率的总数并减去估计参数的数量。
检验统计量近似服从自由度为 (k − c) 的卡方分布，其中 <code>k</code> 是非空单元格的数量，
<code>c</code> 是分布中估计参数的数量。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="chi_squared_goodness_of_fit.js.html">chi_squared_goodness_of_fit.js</a>, <a href="chi_squared_goodness_of_fit.js.html#line28">line 28</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>data</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>数据样本</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>distributionType</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>function</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>返回分布在某一点的函数：
例如二项分布、伯努利分布或泊松分布</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>significance</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>显著性水平</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>卡方拟合优度检验结果</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>// 数据来自 William W. Hines 和 Douglas C. Montgomery 的《工程与管理科学中的概率与统计》中的泊松拟合优度示例 10-19
var data1019 = [
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    2, 2, 2, 2, 2, 2, 2, 2, 2,
    3, 3, 3, 3
];
ss.chiSquaredGoodnessOfFit(data1019, ss.poissonDistribution, 0.05); //= false</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="chunk"><span class="type-signature"></span>chunk<span class="signature">(x, chunkSize)</span><span class="type-signature"> &rarr; {Array.&lt;Array>}</span></h4>

    



<div class="description">
    <p>将数组按指定大小分割为若干子数组。此函数的行为与<a href="http://php.net/manual/en/function.array-chunk.php">PHP的array_chunk</a>函数一致，
因此如果输入数组的长度不能被分割大小整除，则会在末尾插入较小的子数组。</p>
<p><code>x</code> 应为一个数组，<code>chunkSize</code> 应为一个正整数。
数组 <code>x</code> 可以包含任意类型的数据。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="chunk.js.html">chunk.js</a>, <a href="chunk.js.html#line16">line 16</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>样本数据数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>chunkSize</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>每个子数组的大小，必须为正整数</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果分割大小小于1或不是整数，则抛出错误</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;Array></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>分割后的二维数组</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>chunk([1, 2, 3, 4, 5, 6], 2);
// => [[1, 2], [3, 4], [5, 6]]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="ckmeans"><span class="type-signature"></span>ckmeans<span class="signature">(x, nClusters)</span><span class="type-signature"> &rarr; {Array.&lt;Array.&lt;number>>}</span></h4>

    



<div class="description">
    <p>Ckmeans聚类算法是一种基于动态规划的改进聚类方法，相比启发式的Jenks算法更为优化。
该算法由<a href="http://journal.r-project.org/archive/2011-2/RJournal_2011-2_Wang+Song.pdf">Haizhou Wang和Mingzhou Song</a>
提出，通过最小化组内平方偏差和来实现数值数据的最优分组。</p>
<p>该实现基于Ckmeans 3.4.6版本，采用分治法将时间复杂度从O(kn²)优化至O(kn log(n))。</p>
<h3>核心特性</h3>
<ul>
<li>动态规划构建代价矩阵和回溯矩阵</li>
<li>数值稳定性优化：通过中值平移技术</li>
<li>分治策略加速计算过程</li>
</ul>
<h3>参考文献</h3>
<p>《Ckmeans.1d.dp: Optimal k-means Clustering in One Dimension by Dynamic Programming》
作者：Haizhou Wang和Mingzhou Song，刊于The R Journal Vol. 3/2, December 2011</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="ckmeans.js.html">ckmeans.js</a>, <a href="ckmeans.js.html#line207">line 207</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数据集（数值数组）</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>nClusters</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>期望的聚类数目（需小于等于数据长度）</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>当请求聚类数大于数据长度时抛出异常</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>分组后的聚类结果</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>ckmeans([-1, 2, -1, 2, 4, 5, 6, -1, 2, -1], 3);
// 返回：[[-1, -1, -1, -1], [2, 2, 2], [4, 5, 6]]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="coefficientOfVariation"><span class="type-signature"></span>coefficientOfVariation<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><code>变异系数</code>_ 是标准差与均值的比值。
.._<code>变异系数</code>: https://en.wikipedia.org/wiki/Coefficient_of_variation</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="coefficient_of_variation.js.html">coefficient_of_variation.js</a>, <a href="coefficient_of_variation.js.html#line16">line 16</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数据</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>变异系数</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>coefficientOfVariation([1, 2, 3, 4]).toFixed(3); // => 0.516
coefficientOfVariation([1, 2, 3, 4, 5]).toFixed(3); // => 0.527
coefficientOfVariation([-1, 0, 1, 2, 3, 4]).toFixed(3); // => 1.247</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="combinations"><span class="type-signature"></span>combinations<span class="signature">(x, k)</span><span class="type-signature"> &rarr; {Array.&lt;Array>}</span></h4>

    



<div class="description">
    <p>组合的实现
组合是集合的唯一子集 - 在本例中，每次从集合中取出 k 个元素。
https://en.wikipedia.org/wiki/Combination</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="combinations.js.html">combinations.js</a>, <a href="combinations.js.html#line12">line 12</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>任何类型的数据</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>k</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>int</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>每组对象的数量（无放回）</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;Array></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>组合的数组</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>combinations([1, 2, 3], 2); // => [[1,2], [1,3], [2,3]]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="combinationsReplacement"><span class="type-signature"></span>combinationsReplacement<span class="signature">(x, k)</span><span class="type-signature"> &rarr; {Array.&lt;Array>}</span></h4>

    



<div class="description">
    <p>实现<a href="https://en.wikipedia.org/wiki/Combination">组合</a>的替换版本
组合是集合的唯一子集 - 在此情况下，每次从集合中选取 k 个元素。
'替换'意味着一个给定的元素可以被多次选择。
与排列不同，组合不关心顺序。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="combinations_replacement.js.html">combinations_replacement.js</a>, <a href="combinations_replacement.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>任意类型的数据</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>k</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>int</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>每组对象的数量（允许重复）</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;Array></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>组合的数组</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>combinationsReplacement([1, 2], 2); // => [[1, 1], [1, 2], [2, 2]]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="combineMeans"><span class="type-signature"></span>combineMeans<span class="signature">(mean1, n1, mean2, n2)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>当需要合并两个已知均值的数值列表时，
不必重新以线性时间计算合并后列表的均值。
可以通过提供第一个列表的均值和数值数量，以及第二个列表的均值和数值数量，
使用此函数来计算合并后的均值。</p>
</div>





<dl class="details">

    

    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>3.0.0</li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="combine_means.js.html">combine_means.js</a>, <a href="combine_means.js.html#line17">line 17</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>mean1</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第一个列表的均值</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>n1</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第一个列表中的数值数量</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>mean2</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第二个列表的均值</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>n2</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第二个列表中的数值数量</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>合并后的均值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>combineMeans(5, 3, 4, 3); // => 4.5</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="combineVariances"><span class="type-signature"></span>combineVariances<span class="signature">(variance1, mean1, n1, variance2, mean2, n2)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>当需要合并两个已知方差的数值列表时，不必重新线性计算合并后列表的方差。
可以使用此函数通过提供第一个列表的方差、均值、数量，
以及第二个列表的方差、均值、数量来计算合并后的方差。</p>
</div>





<dl class="details">

    

    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>3.0.0</li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="combine_variances.js.html">combine_variances.js</a>, <a href="combine_variances.js.html#line20">line 20</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>variance1</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第一个列表的方差</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>mean1</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第一个列表的均值</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>n1</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第一个列表中的项目数量</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>variance2</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第二个列表的方差</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>mean2</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第二个列表的均值</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>n2</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第二个列表中的项目数量</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>合并后的均值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>combineVariances(14 / 3, 5, 3, 8 / 3, 4, 3); // => 47 / 12</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="createGroups"><span class="type-signature">(private) </span>createGroups<span class="signature">(labels)</span><span class="type-signature"> &rarr; {Array.&lt;Array.&lt;number>>}</span></h4>

    



<div class="description">
    <p>创建组ID到点ID的查找表</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="silhouette.js.html">silhouette.js</a>, <a href="silhouette.js.html#line52">line 52</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>labels</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>数据点标签数组，长度必须与points一致，
且取值范围为[0..G-1]，其中G为分组总数</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>长度G的数组，每个元素为对应组内数据点索引的数组</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="cumulativeStdLogisticProbability"><span class="type-signature"></span>cumulativeStdLogisticProbability<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><strong><a href="https://en.wikipedia.org/wiki/Logistic_distribution">逻辑分布累积分布函数</a></strong></p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="cumulative_std_logistic_probability.js.html">cumulative_std_logistic_probability.js</a>, <a href="cumulative_std_logistic_probability.js.html#line7">line 7</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>标准逻辑分布累积概率</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="cumulativeStdNormalProbability"><span class="type-signature"></span>cumulativeStdNormalProbability<span class="signature">(z)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><strong><a href="http://en.wikipedia.org/wiki/Standard_normal_table">累积标准正态概率</a></strong></p>
<p>由于无法为每个正态分布打印概率表（因为正态分布有无限多种），通常的做法是将正态分布转换为标准正态分布，
然后使用标准正态分布表查找概率。</p>
<p>你可以使用 <code>.5 + .5 * errorFunction(x / Math.sqrt(2))</code> 来计算概率，
而不是从表格中查找。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="cumulative_std_normal_probability.js.html">cumulative_std_normal_probability.js</a>, <a href="cumulative_std_normal_probability.js.html#line15">line 15</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>z</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>标准正态分布的z值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>累积标准正态概率</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="equalIntervalBreaks"><span class="type-signature"></span>equalIntervalBreaks<span class="signature">(x, nClasses)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>

    



<div class="description">
    <p>给定一个数组 x，此函数将找到 x 的范围，并返回一个可用于将 x 分类为多个类别的断点数组。
返回的数组总是比类别数多 1，因为它包含最小值。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="equal_interval_breaks.js.html">equal_interval_breaks.js</a>, <a href="equal_interval_breaks.js.html#line14">line 14</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>一个数值数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>nClasses</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>所需的类别数</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;number></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>类别断点位置的数组</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>equalIntervalBreaks([1, 2, 3, 4, 5, 6], 4); // => [1, 2.25, 3.5, 4.75, 6]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="errorFunction"><span class="type-signature"></span>errorFunction<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><strong><a href="http://en.wikipedia.org/wiki/Error_function">高斯误差函数</a></strong></p>
<p><code>errorFunction(x/(sd * Math.sqrt(2)))</code> 表示在标准偏差为 <code>sd</code> 的正态分布中，一个值在距离均值 <code>x</code> 范围内的概率。</p>
<p>该函数返回对精确值的数值近似。它使用 Horner 方法来计算 τ (tau) 的多项式。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="error_function.js.html">error_function.js</a>, <a href="error_function.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>误差估计值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>errorFunction(1).toFixed(2); // => '0.84'</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="euclideanDistance"><span class="type-signature"></span>euclideanDistance<span class="signature">(left, right)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>计算两个点之间的欧几里得距离。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="euclidean_distance.js.html">euclidean_distance.js</a>, <a href="euclidean_distance.js.html#line7">line 7</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>left</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第一个N维点。</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>right</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第二个N维点。</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>距离。</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="extent"><span class="type-signature"></span>extent<span class="signature">(x)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>

    



<div class="description">
    <p>计算数组中的最小值和最大值。</p>
<p>该函数的时间复杂度为 <code>O(n)</code>，即线性时间，与数组的长度成正比。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="extent.js.html">extent.js</a>, <a href="extent.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数据点的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果数组 x 的长度小于1</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;number></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>最小值和最大值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>extent([1, 2, 3, 4]);
// => [1, 4]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="extentSorted"><span class="type-signature"></span>extentSorted<span class="signature">(x)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>

    



<div class="description">
    <p>范围是指数组中的最小值和最大值。对于一个已排序的数组，
数组中的第一个元素始终是最小值，而最后一个元素始终是最大值，因此这个计算可以在一步内完成，即常数时间复杂度。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="extent_sorted.js.html">extent_sorted.js</a>, <a href="extent_sorted.js.html#line10">line 10</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;number></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>最小值和最大值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>extentSorted([-100, -10, 1, 2, 5]); // => [-100, 5]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="factorial"><span class="type-signature"></span>factorial<span class="signature">(n)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Factorial">阶乘</a>，通常写作 n!，是所有小于或等于 n 的正整数的乘积。
阶乘通常以递归方式实现，但这种迭代方法显著更快且更简单。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="factorial.js.html">factorial.js</a>, <a href="factorial.js.html#line11">line 11</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>n</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入，必须为大于或等于 1 的整数</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果 n 小于 0 或不是整数</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>阶乘：n!</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>factorial(5); // => 120</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="fillMatrices"><span class="type-signature">(private) </span>fillMatrices<span class="signature">(data, matrix, backtrackMatrix)</span><span class="type-signature"></span></h4>

    



<div class="description">
    <p>初始化Ckmeans算法的主矩阵并启动分治聚类计算策略</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="ckmeans.js.html">ckmeans.js</a>, <a href="ckmeans.js.html#line133">line 133</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>data</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>已排序的数值数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>matrix</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>动态规划矩阵</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>backtrackMatrix</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>回溯矩阵</p>
                
            </td>
        </tr>

    
    </tbody>
</table>
















</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="fillMatrixColumn"><span class="type-signature">(private) </span>fillMatrixColumn<span class="signature">(iMin, iMax, cluster, matrix, backtrackMatrix, sums, sumsOfSquares)</span><span class="type-signature"></span></h4>

    



<div class="description">
    <p>递归执行分治策略计算指定簇的矩阵列</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="ckmeans.js.html">ckmeans.js</a>, <a href="ckmeans.js.html#line44">line 44</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>iMin</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>当前簇计算的最小索引</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>iMax</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>当前簇计算的最大索引</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>cluster</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>当前计算的簇索引</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>matrix</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>动态规划矩阵</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>backtrackMatrix</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>回溯矩阵</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>sums</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>累积和数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>sumsOfSquares</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>平方累积和数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>
















</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="gamma"><span class="type-signature"></span>gamma<span class="signature">(n)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>使用Nemes近似法计算值的<a href="https://en.wikipedia.org/wiki/Gamma_function">伽马函数</a>。
n的伽马函数等价于(n-1)!，但与阶乘函数不同的是，伽马函数对所有实数n（除了零和负整数）都有定义（此时返回NaN）。
注意，伽马函数也对复数有定义，但此实现目前不处理复数作为输入值。
Nemes近似法在<a href="https://arxiv.org/abs/1003.6020">这里</a>定义为定理2.2。
负值使用<a href="https://en.wikipedia.org/wiki/Gamma_function#Properties">欧拉反射公式</a>进行计算。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="gamma.js.html">gamma.js</a>, <a href="gamma.js.html#line18">line 18</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>n</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>任何实数，除了零和负整数。</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>输入值的伽马函数值。</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>gamma(11.5); // 11899423.084037038
gamma(-11.5); // 2.29575810481609e-8
gamma(5); // 24</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="gammaln"><span class="type-signature"></span>gammaln<span class="signature">(n)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>使用Lanczos近似法计算<a href="https://en.wikipedia.org/wiki/Gamma_function">伽马函数</a>的对数值。
该函数接受任何大于0的实数n作为输入。
该函数对于普通伽马函数无法处理的大数值n（n &gt; 165）非常有用。
代码基于Lanczos的伽马近似法，定义见<a href="http://my.fit.edu/~gabdo/gamma.txt">此处</a>。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="gammaln.js.html">gammaln.js</a>, <a href="gammaln.js.html#line28">line 28</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>n</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>任何大于零的实数。</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>输入值的伽马函数的对数值。</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>gammaln(500); // 2605.1158503617335
gammaln(2.4); // 0.21685932244884043</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="geometricMean"><span class="type-signature"></span>geometricMean<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Geometric_mean">几何平均数</a>是一种适用于不同量级数据的均值计算方法。</p>
<p>该方法计算n个数字乘积的n次方根。</p>
<p>几何平均数在分析**<a href="https://en.wikipedia.org/wiki/Geometric_mean#Proportional_growth">比例增长</a>**时特别有用：
当给定多年增长率（如_80%, 16.66% 和 42.85%_）时，算术平均数会错误估计平均增长率，
而几何平均数能准确计算出与多年增长结果等效的复合增长率。</p>
<p>算法时间复杂度为<code>O(n)</code>，与数组长度呈线性关系。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="geometric_mean.js.html">geometric_mean.js</a>, <a href="geometric_mean.js.html#line30">line 30</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数据点的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>
<ul>
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>当x为空时抛出</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>当x包含负数时抛出</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    </ul>
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>几何平均数</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>var growthRates = [1.80, 1.166666, 1.428571];
var averageGrowth = ss.geometricMean(growthRates);
var averageGrowthRates = [averageGrowth, averageGrowth, averageGrowth];
var startingValue = 10;
var startingValueMean = 10;
growthRates.forEach(function(rate) {
  startingValue *= rate;
});
averageGrowthRates.forEach(function(rate) {
  startingValueMean *= rate;
});
startingValueMean === startingValue;</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="harmonicMean"><span class="type-signature"></span>harmonicMean<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Harmonic_mean">调和平均数</a>是一种
通常用于计算比率平均值的均值函数。
该均值通过取输入数字倒数算术平均数的倒数来计算。</p>
<p>这是一种<a href="https://en.wikipedia.org/wiki/Central_tendency">集中趋势度量</a>：
用于寻找一组数字的典型值或中心值的方法。</p>
<p>该函数的时间复杂度为<code>O(n)</code>，即线性时间，与数组长度成正比。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="harmonic_mean.js.html">harmonic_mean.js</a>, <a href="harmonic_mean.js.html#line18">line 18</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数据点的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>
<ul>
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>如果x为空</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>如果x包含负数</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    </ul>
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>调和平均数</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>harmonicMean([2, 3]).toFixed(2) // => '2.40'</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="interquartileRange"><span class="type-signature"></span>interquartileRange<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Interquartile_range">四分位距</a>是
一种衡量统计离散度的指标，用于描述分布的分散、扩展或集中程度。
它通过计算第三四分位数与第一四分位数之间的差值得出。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="interquartile_range.js.html">interquartile_range.js</a>, <a href="interquartile_range.js.html#line14">line 14</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数字的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>四分位距：下四分位数和上四分位数之间的跨度，
分别为0.25和0.75</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>interquartileRange([0, 1, 2, 3]); // => 2</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="inverseErrorFunction"><span class="type-signature"></span>inverseErrorFunction<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>逆<a href="http://en.wikipedia.org/wiki/Error_function">高斯误差函数</a>
返回一个数值近似值，该值会导致<code>errorFunction()</code>返回x。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="inverse_error_function.js.html">inverse_error_function.js</a>, <a href="inverse_error_function.js.html#line8">line 8</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>误差函数的值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>估计的逆值</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="jenks"><span class="type-signature"></span>jenks<span class="signature">(data, nClasses)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>

    



<div class="description">
    <p><strong><a href="http://en.wikipedia.org/wiki/Jenks_natural_breaks_optimization">Jenks自然间断优化算法</a></strong>
是一种常用于制图和可视化中的算法，用于决定数据值的分组，以最小化组内方差并最大化组间差异。</p>
<p>例如，制图师通常使用Jenks算法来选择在<a href="https://en.wikipedia.org/wiki/Choropleth_map">等值区域图</a>中
哪些值被分配给哪些颜色。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="jenks.js.html">jenks.js</a>, <a href="jenks.js.html#line17">line 17</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>data</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数据，作为数字值的数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>nClasses</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>期望的类别数量</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;number></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>类别间断点的数组
// 将数据分成3个间断点
jenks([1, 2, 4, 5, 7, 9, 10, 20], 3) // = [1, 7, 20, 20]</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="kMeansCluster"><span class="type-signature"></span>kMeansCluster<span class="signature">(points, numCluster, randomSource)</span><span class="type-signature"> &rarr; {<a href="global.html#kMeansReturn">kMeansReturn</a>}</span></h4>

    



<div class="description">
    <p>执行k均值聚类算法</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="k_means_cluster.js.html">k_means_cluster.js</a>, <a href="k_means_cluster.js.html#line23">line 23</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>points</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>待聚类点的N维坐标数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>numCluster</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>需要创建的聚类数量</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>randomSource</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>function</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>可选随机源，生成[0,1)区间的均匀分布值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>当存在无关联数据点的聚类中心时抛出异常</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code><a href="global.html#kMeansReturn">kMeansReturn</a></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>包含标签数组和聚类中心数组的对象</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>kMeansCluster([[0.0, 0.5], [1.0, 0.5]], 2); // => {labels: [0, 1], centroids: [[0.0, 0.5], [1.0 0.5]]}</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="labelPoints"><span class="type-signature">(private) </span>labelPoints<span class="signature">(points, centroids)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>

    



<div class="description">
    <p>根据当前聚类中心为数据点分配簇标签</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="k_means_cluster.js.html">k_means_cluster.js</a>, <a href="k_means_cluster.js.html#line48">line 48</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>points</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>数据点坐标数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>centroids</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>当前聚类中心坐标数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;number></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>数据点对应的簇标签数组</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="linearRegression"><span class="type-signature"></span>linearRegression<span class="signature">(data)</span><span class="type-signature"> &rarr; {Object}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Simple_linear_regression">简单线性回归</a>
用于在坐标点集中寻找最佳拟合直线。本算法通过最小二乘法
计算回归直线的斜率和截距。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="linear_regression.js.html">linear_regression.js</a>, <a href="linear_regression.js.html#line12">line 12</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>data</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>二维数据数组，格式为
<code>[[0, 1], [2, 3]]</code></p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Object</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>包含回归直线斜率和截距的对象</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>linearRegression([[0, 0], [1, 1]]); // => { m: 1, b: 0 }</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="linearRegressionLine"><span class="type-signature"></span>linearRegressionLine<span class="signature">(mb)</span><span class="type-signature"> &rarr; {function}</span></h4>

    



<div class="description">
    <p>给定 <code>linearRegression</code> 的输出：一个包含 <code>m</code> 和 <code>b</code> 值的对象，
分别表示斜率和截距，生成一个将 x 值转换为 y 值的线性函数。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="linear_regression_line.js.html">linear_regression_line.js</a>, <a href="linear_regression_line.js.html#line14">line 14</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>mb</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Object</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含 <code>m</code> 和 <code>b</code> 成员的对象，表示所需直线的斜率和截距</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>function</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>计算直线上任意给定 x 值对应的 y 值的方法</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>var l = linearRegressionLine(linearRegression([[0, 0], [1, 1]]));
l(0) // = 0
l(2) // = 2
linearRegressionLine({ b: 0, m: 1 })(1); // => 1
linearRegressionLine({ b: 1, m: 1 })(1); // => 2</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="logAverage"><span class="type-signature"></span>logAverage<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/https://en.wikipedia.org/wiki/Geometric_mean#Relationship_with_logarithms">对数平均值</a>
是一种适用于大或小乘积数组的几何平均值的等效计算方法。</p>
<p>它通过计算元素的对数平均值并取指数来得到。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="log_average.js.html">log_average.js</a>, <a href="log_average.js.html#line12">line 12</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数据点的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>
<ul>
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>如果 x 为空</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>如果 x 包含负数</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    </ul>
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>几何平均值</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="logit"><span class="type-signature"></span>logit<span class="signature">(p)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Logit">Logit</a> 是累积标准Logistic概率的反函数，
也被称为Logistic分位数函数。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="logit.js.html">logit.js</a>, <a href="logit.js.html#line8">line 8</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>p</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>logit</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="lowerBound"><span class="type-signature"></span>lowerBound<span class="signature">(x, value)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>二分查找下界索引（第一个大于等于目标值的位置）</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="quantile_rank_sorted.js.html">quantile_rank_sorted.js</a>, <a href="quantile_rank_sorted.js.html#line63">line 63</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>已排序数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>value</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>目标值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>下界索引</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="makeMatrix"><span class="type-signature">(private) </span>makeMatrix<span class="signature">(columns, rows)</span><span class="type-signature"> &rarr; {Array.&lt;Array.&lt;number>>}</span></h4>

    



<div class="description">
    <p>创建一个新的列 x 行矩阵。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="make_matrix.js.html">make_matrix.js</a>, <a href="make_matrix.js.html#line11">line 11</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>columns</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>列数</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>rows</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>行数</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>矩阵</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>makeMatrix(10, 10);</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="max"><span class="type-signature"></span>max<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>计算数组中的最大值。</p>
<p>该算法的时间复杂度为 <code>O(n)</code>，即线性时间，与数组的长度成正比。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="max.js.html">max.js</a>, <a href="max.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数据点的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果数组 x 的长度小于 1</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>最大值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>max([1, 2, 3, 4]);
// => 4</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="maxSorted"><span class="type-signature"></span>maxSorted<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>最大值是数组中的最高数值。对于已排序的数组，
数组的最后一个元素始终是最大的，因此这个计算
可以在一步内完成，即常数时间复杂度。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="max_sorted.js.html">max_sorted.js</a>, <a href="max_sorted.js.html#line11">line 11</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>最大值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>maxSorted([-100, -10, 1, 2, 5]); // => 5</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="mean"><span class="type-signature"></span>mean<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>均值，也称为平均数，
是所有值的和除以值的数量。
这是一种<a href="https://en.wikipedia.org/wiki/Central_tendency">集中趋势的度量</a>：
一种寻找一组数字的典型或中心值的方法。</p>
<p>该算法的时间复杂度为<code>O(n)</code>，即线性时间，与数组的长度成正比。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="mean.js.html">mean.js</a>, <a href="mean.js.html#line17">line 17</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数据点的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果x的长度小于1</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>均值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>mean([0, 10]); // => 5</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="meanDistanceFromPointToGroup"><span class="type-signature">(private) </span>meanDistanceFromPointToGroup<span class="signature">(which, group, distances)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>计算点到指定组的平均距离（可包含自身所在组）</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="silhouette.js.html">silhouette.js</a>, <a href="silhouette.js.html#line121">line 121</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>which</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>当前点索引</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>group</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>目标组的数据点索引数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>distances</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>对称方阵形式的点间距离矩阵</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>当前点到目标组的平均距离</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="meanDistanceToNearestGroup"><span class="type-signature">(private) </span>meanDistanceToNearestGroup<span class="signature">(which, labels, groupings, distances)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>计算当前点到最近组（由最近邻点确定）的平均距离</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="silhouette.js.html">silhouette.js</a>, <a href="silhouette.js.html#line94">line 94</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>which</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>当前点索引</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>labels</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>数据点标签数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>groupings</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>组结构数组，每个元素为对应组内数据点索引的数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>distances</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>对称方阵形式的点间距离矩阵</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>当前点到最近组的平均距离</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="meanSimple"><span class="type-signature"></span>meanSimple<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>均值（算术平均数）是数据集中所有观测值的总和除以观测数量，
属于<a href="https://en.wikipedia.org/wiki/Central_tendency">集中趋势度量</a>方法，
用于寻找数据集的典型中心值。</p>
<p>本简单均值函数内部采用逐次累加法计算，未考虑浮点加法误差。
如需更高计算精度，应改用标准<a href="global.html#mean"><code>mean</code></a>方法。</p>
<p>时间复杂度为<code>O(n)</code>，与数组长度成线性关系。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="mean_simple.js.html">mean_simple.js</a>, <a href="mean_simple.js.html#line19">line 19</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数据点的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>当数组为空时抛出异常</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>算术平均数</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>meanSimple([0, 10]); // => 5</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="median"><span class="type-signature"></span>median<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Median">中位数</a>是
一组数字的中间值。当存在异常值导致<code>mean()</code>（均值）偏离时，
中位数通常是“中间值”的良好指标。
这是<a href="https://en.wikipedia.org/wiki/Central_tendency">集中趋势</a>的一种度量方法：
用于寻找一组数字的典型或中心值。</p>
<p>中位数不一定是列表中的元素之一：如果列表长度为偶数且两个中心值不同，
则中位数可以是这两个元素的平均值。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="median.js.html">median.js</a>, <a href="median.js.html#line18">line 18</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>中位数值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>median([10, 2, 5, 100, 2, 1]); // => 3.5</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="medianAbsoluteDeviation"><span class="type-signature"></span>medianAbsoluteDeviation<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Median_absolute_deviation">中位绝对偏差</a>是一种
鲁棒的统计离散度量。相比标准差，它对异常值更具抵抗力。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="median_absolute_deviation.js.html">median_absolute_deviation.js</a>, <a href="median_absolute_deviation.js.html#line12">line 12</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>中位绝对偏差</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>medianAbsoluteDeviation([1, 1, 2, 2, 4, 6, 9]); // => 1</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="medianSorted"><span class="type-signature"></span>medianSorted<span class="signature">(sorted)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Median">中位数</a>是
数据集的中间值。当存在偏离平均值的异常值时，
该指标能更好地反映数据的中心位置。属于
<a href="https://en.wikipedia.org/wiki/Central_tendency">集中趋势度量</a>方法，
用于寻找数据集的典型中心值。</p>
<p>中位数不一定是数据集中的元素：当数据量为偶数时，
其值可能为两个中间元素的平均值。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="median_sorted.js.html">median_sorted.js</a>, <a href="median_sorted.js.html#line18">line 18</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>sorted</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>已排序数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>中位数值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>medianSorted([10, 2, 5, 100, 2, 1]); // => 52.5</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="min"><span class="type-signature"></span>min<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>最小值是数组中的最低数字。
该算法的时间复杂度为 <code>O(n)</code>，即线性时间，与数组的长度成正比。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="min.js.html">min.js</a>, <a href="min.js.html#line11">line 11</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数据点的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果数组 x 的长度小于1</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>最小值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>min([1, 5, -10, 100, 2]); // => -10</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="minSorted"><span class="type-signature"></span>minSorted<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>最小值是数组中的最小数字。对于一个已排序的数组，
数组的第一个元素总是最小的，因此这个计算可以在一步内完成，即常数时间复杂度。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="min_sorted.js.html">min_sorted.js</a>, <a href="min_sorted.js.html#line10">line 10</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>最小值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>minSorted([-100, -10, 1, 2, 5]); // => -100</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="mode"><span class="type-signature"></span>mode<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Mode_%28statistics%29">众数</a>是
数据集中出现频率最高的元素。当存在多个相同频率的众数时，
本算法将返回最后遇到的那个值。</p>
<p>这是<a href="https://en.wikipedia.org/wiki/Central_tendency">集中趋势度量</a>方法，
用于寻找数据集的典型中心值。</p>
<p>本算法时间复杂度为<code>O(n log(n))</code>，因为需要先对数组进行排序，
再进行<code>O(n)</code>复杂度的众数搜索。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="mode.js.html">mode.js</a>, <a href="mode.js.html#line20">line 20</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>众数</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>mode([0, 0, 1]); // => 0</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="modeFast"><span class="type-signature"></span>modeFast<span class="signature">(x)</span><span class="type-signature"> &rarr; (nullable) {*}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Mode_%28statistics%29">众数</a>是
数据集中出现频率最高的元素。一个数据集可能包含
多个众数：当出现频率相同时，本算法将返回最近遇到的众数。</p>
<p>modeFast使用Map对象替代<code>mode</code>方法的排序数组方案来跟踪状态，
因此效率更高且支持所有可通过<code>==</code>比较的数据类型。
要求
<a href="https://kangax.github.io/compat-table/es6/#test-Map">JavaScript环境支持Map对象</a>，
若不可用将抛出错误。</p>
<p>这是<a href="https://en.wikipedia.org/wiki/Central_tendency">集中趋势度量</a>方法，
用于寻找数据集的典型中心值。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="mode_fast.js.html">mode_fast.js</a>, <a href="mode_fast.js.html#line24">line 24</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;*></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数据点的样本数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>
<ul>
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>当JavaScript环境不支持Map时抛出</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>ReferenceError</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>输入数组为空时抛出</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    </ul>
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>*</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>众数</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>modeFast(['rabbits', 'rabbits', 'squirrels']); // => 'rabbits'</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="modeSorted"><span class="type-signature"></span>modeSorted<span class="signature">(sorted)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Mode_%28statistics%29">众数</a>是数据集中出现次数最多的数值。
一个数据集可能存在多个众数：当出现频率相同的多个值时，本算法将返回最后出现的众数。
这是<a href="https://en.wikipedia.org/wiki/Central_tendency">集中趋势的度量</a>方法：
用于寻找数据集的典型值或中心值。</p>
<p>由于输入已排序，算法时间复杂度为<code>O(n)</code>。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="mode_sorted.js.html">mode_sorted.js</a>, <a href="mode_sorted.js.html#line15">line 15</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>sorted</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>已排序的数据样本（需包含至少一个数据点）</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>当输入为空时抛出错误</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>众数值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>modeSorted([0, 0, 1]); // => 0</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="multiQuantileSelect"><span class="type-signature"></span>multiQuantileSelect<span class="signature">(arr, p)</span><span class="type-signature"></span></h4>

    



<div class="description">
    <p>多分位点选择优化算法</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="quantile.js.html">quantile.js</a>, <a href="quantile.js.html#line60">line 60</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>arr</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>目标数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>p</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>分位点数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>
















</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="numericSort"><span class="type-signature">(private) </span>numericSort<span class="signature">(x)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>

    



<div class="description">
    <p>对数字数组按其数值大小进行排序，确保数组不会原地修改。</p>
<p>这是必要的，因为 JavaScript 中 .sort 的默认行为是将数组作为字符串值进行排序</p>
<pre><code>[1, 10, 12, 102, 20].sort()
// 输出
[1, 10, 102, 12, 20]
</code></pre>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="numeric_sort.js.html">numeric_sort.js</a>, <a href="numeric_sort.js.html#line16">line 16</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;number></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>排序后的数组</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>numericSort([3, 2, 1]) // => [1, 2, 3]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="permutationTest"><span class="type-signature"></span>permutationTest<span class="signature">(sampleX, sampleY, alternative, k, randomSource<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>执行<a href="https://en.wikipedia.org/wiki/Resampling_(statistics)#Permutation_tests">置换检验</a>
用于判断两个数据集是否具有<em>显著性差异</em>，使用组间均值差作为检验统计量。
支持以下假设类型：</p>
<ul>
<li>two_side = 零假设：两个分布相同（双尾检验）</li>
<li>greater = 零假设：样本X观测值通常小于样本Y（右尾检验）</li>
<li>less = 零假设：样本X观测值通常大于样本Y（左尾检验）
<a href="https://en.wikipedia.org/wiki/One-_and_two-tailed_tests">了解单尾与双尾检验的区别</a></li>
</ul>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="permutation_test.js.html">permutation_test.js</a>, <a href="permutation_test.js.html#line25">line 25</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>sampleX</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>第一数据集（如实验组）</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>sampleY</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>第二数据集（如对照组）</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>alternative</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>string</code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>备择假设类型，可选'two_sided'(默认), 'greater', 或'less'</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>k</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>置换分布生成值数量</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>randomSource</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>function</code></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    Math.random
                
                </td>
            

            <td class="description last">
                <p>可选随机源</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>p值 在零假设下观测到当前（或更极端）组间差异的概率</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>var control = [2, 5, 3, 6, 7, 2, 5];
var treatment = [20, 5, 13, 12, 7, 2, 2];
permutationTest(control, treatment); // ~0.1324</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="permutationsHeap"><span class="type-signature"></span>permutationsHeap<span class="signature">(elements)</span><span class="type-signature"> &rarr; {Array.&lt;Array>}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Heap%27s_algorithm">Heap算法</a>的实现，
用于生成排列。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="permutations_heap.js.html">permutations_heap.js</a>, <a href="permutations_heap.js.html#line8">line 8</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>elements</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>任意类型的数据</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;Array></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>排列的数组</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="poissonDistribution"><span class="type-signature"></span>poissonDistribution<span class="signature">(lambda)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Poisson_distribution">泊松分布</a>是离散概率分布，
表示在固定时间/空间间隔内事件发生次数的概率，当事件以已知平均速率独立发生时适用。
其特征由严格正数的平均到达率（发生率）<code>λ</code>决定。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="poisson_distribution.js.html">poisson_distribution.js</a>, <a href="poisson_distribution.js.html#line11">line 11</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>lambda</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>泊松分布参数（事件平均发生率）</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;number></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>泊松分布概率值数组</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="probit"><span class="type-signature"></span>probit<span class="signature">(p)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Probit">Probit</a> 是 cumulativeStdNormalProbability() 的反函数，
也被称为正态分位数函数。</p>
<p>它返回与均值相差的标准差数量，表示在正态分布中可以找到第 p 个分位数的位置。
例如，probit(0.5 + 0.6827/2) ≈ 1，因为 68.27% 的值通常分布在均值上下 1 个标准差范围内。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="probit.js.html">probit.js</a>, <a href="probit.js.html#line14">line 14</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>p</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>probit</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="product"><span class="type-signature"></span>product<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Product_(mathematics)">乘积</a> 是一个数组中所有数字相乘的结果，从1作为乘法单位元开始。</p>
<p>该算法的时间复杂度为 <code>O(n)</code>，即线性时间，与数组的长度成正比。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="product.js.html">product.js</a>, <a href="product.js.html#line11">line 11</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>输入数组中所有数字的乘积</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>product([1, 2, 3, 4]); // => 24</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="quantile"><span class="type-signature"></span>quantile<span class="signature">(x, p)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Quantile">分位数</a>计算函数：
本实现基于总体分位数算法，假设已知完整数据集。遵循维基百科
<a href="http://en.wikipedia.org/wiki/Quantile#Quantiles_of_a_population">总体分位数</a>算法。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="quantile.js.html">quantile.js</a>, <a href="quantile.js.html#line15">line 15</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>数值型数据数组（需包含至少一个元素）</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>p</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>
|

<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>分位点或分位点数组（取值范围[0,1]）</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>分位数值或分位数数组</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>quantile([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 0.5); // => 9</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="quantileIndex"><span class="type-signature"></span>quantileIndex<span class="signature">(len, p)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>分位数索引计算函数</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="quantile.js.html">quantile.js</a>, <a href="quantile.js.html#line99">line 99</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>len</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>数组长度</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>p</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>分位点</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>计算后的索引值</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="quantileRank"><span class="type-signature"></span>quantileRank<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>该函数返回给定值在给定数组中的分位数位置。它会在每次运行前复制并排序数组，
因此如果你知道数组已经排序，应该使用 <code>quantileRankSorted</code> 代替。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="quantile_rank.js.html">quantile_rank.js</a>, <a href="quantile_rank.js.html#line16">line 16</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>quantileRank([4, 3, 1, 2], 3); // => 0.75
quantileRank([4, 3, 2, 3, 1], 3); // => 0.7
quantileRank([2, 4, 1, 3], 6); // => 1
quantileRank([5, 3, 1, 2, 3], 4); // => 0.8</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="quantileRankSorted"><span class="type-signature"></span>quantileRankSorted<span class="signature">(x, value)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>本函数计算给定值在已排序数组中的分位数排名。通过二分查找算法，可在对数时间内完成计算。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="quantile_rank_sorted.js.html">quantile_rank_sorted.js</a>, <a href="quantile_rank_sorted.js.html#line15">line 15</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>已排序输入数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>value</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>目标数值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>分位数排名（范围[0,1]）</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>quantileRankSorted([1, 2, 3, 4], 3); // => 0.75
quantileRankSorted([1, 2, 3, 3, 4], 3); // => 0.7
quantileRankSorted([1, 2, 3, 4], 6); // => 1
quantileRankSorted([1, 2, 3, 3, 5], 4); // => 0.8</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="quantileSelect"><span class="type-signature"></span>quantileSelect<span class="signature">(arr, k, left, right)</span><span class="type-signature"></span></h4>

    



<div class="description">
    <p>分位数选择函数（基于快速选择算法）</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="quantile.js.html">quantile.js</a>, <a href="quantile.js.html#line43">line 43</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>arr</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>目标数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>k</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>目标索引</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>left</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>左边界</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>right</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>右边界</p>
                
            </td>
        </tr>

    
    </tbody>
</table>
















</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="quantileSorted"><span class="type-signature"></span>quantileSorted<span class="signature">(x, p)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>分位数计算内部实现（输入已排序数组时可避免重复排序，提升计算效率）</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="quantile_sorted.js.html">quantile_sorted.js</a>, <a href="quantile_sorted.js.html#line12">line 12</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>已排序数据样本（需包含至少一个数据点）</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>p</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>分位点：取值范围[0, 1]的数值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>
<ul>
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>当p超出[0,1]范围时抛出错误</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>当输入数组为空时抛出错误</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    </ul>
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>分位数值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>quantileSorted([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 0.5); // => 9</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="quickselect"><span class="type-signature"></span>quickselect<span class="signature">(arr, k, left<span class="signature-attributes">opt</span>, right<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {void}</span></h4>

    



<div class="description">
    <p>重新排列 <code>arr</code> 中的元素，使得 <code>[left, k]</code> 范围内的所有元素都是最小的。
第 <code>k</code> 个元素将是 <code>[left, right]</code> 范围内第 <code>(k - left + 1)</code> 小的值。</p>
<p>实现 Floyd-Rivest 选择算法 https://en.wikipedia.org/wiki/Floyd-Rivest_algorithm</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="quickselect.js.html">quickselect.js</a>, <a href="quickselect.js.html#line17">line 17</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>arr</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>k</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last">
                <p>枢轴索引</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>left</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last">
                <p>左索引</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>right</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last">
                <p>右索引</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>void</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>会修改输入数组</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>var arr = [65, 28, 59, 33, 21, 56, 22, 95, 50, 12, 90, 53, 28, 77, 39];
quickselect(arr, 8);
// = [39, 28, 28, 33, 21, 12, 22, 50, 53, 56, 59, 65, 90, 77, 95]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="rSquared"><span class="type-signature"></span>rSquared<span class="signature">(x, func)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Coefficient_of_determination">决定系数（R²）</a>
用于评估回归函数<code>f</code>对数据的拟合程度，计算预测值与实际值的平方差异和。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="r_squared.js.html">r_squared.js</a>, <a href="r_squared.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数据：二维数组结构，每项格式为[自变量, 因变量]</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>func</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>function</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>回归函数（接受自变量值返回预测值）</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>R²值（范围[0,1]）</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>var samples = [[0, 0], [1, 1]];
var regressionLine = linearRegressionLine(linearRegression(samples));
rSquared(samples, regressionLine); // = 1 表示完美拟合</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="relativeError"><span class="type-signature"></span>relativeError<span class="signature">(actual, expected)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>相对误差计算函数。</p>
<p>相对误差计算比表面更为复杂[1,2]。传统计算公式为<code>|(A-E)/E|</code>，但存在两个关键问题：</p>
<ol>
<li>当期望值为零时，任何非零实际值都会产生无限大相对误差，这与直觉相悖（如期望电压为0时，测量到0.1伏特不应视为无穷大误差）</li>
<li>该公式不满足数学度量的严格定义[3]。[4]提出使用<code>|ln(|A/E|)|</code>定义，但仅适用于正值场景（如-10与10的误差会被误判为0）</li>
</ol>
<p>本实现遵循常规方案：</p>
<ul>
<li>当实际值与期望值均为零时返回0</li>
<li>当期望值为零而实际值非零时返回Infinity</li>
<li>其他情况返回<code>|(A-E)/E|</code></li>
</ul>
<p>[1] 零点相对误差计算问题 https://math.stackexchange.com/questions/677852/how-to-calculate-relative-error-when-true-value-is-zero
[2] 相对变化与差异 https://en.wikipedia.org/wiki/Relative_change_and_difference
[3] 数学度量定义 https://en.wikipedia.org/wiki/Metric_(mathematics)#Definition
[4] F.W.J.奥尔弗，《误差算术新方法》SIAM数值分析期刊, 15(2), 1978, DOI:10.1137/0715024</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="relative_error.js.html">relative_error.js</a>, <a href="relative_error.js.html#line22">line 22</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>actual</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>实际测量值</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>expected</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>期望理论值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>相对误差计算结果</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="rootMeanSquare"><span class="type-signature"></span>rootMeanSquare<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>均方根（Root Mean Square, RMS）是一种均值函数，
用于衡量一组数的大小，而不考虑它们的符号。
它是输入数值平方的平均值的平方根。
该算法的时间复杂度为 <code>O(n)</code>，即线性时间，与数组的长度成正比。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="root_mean_square.js.html">root_mean_square.js</a>, <a href="root_mean_square.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含一个或多个数据点的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果 x 为空</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>均方根</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>rootMeanSquare([-1, 1, -1, 1]); // => 1</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sample"><span class="type-signature"></span>sample<span class="signature">(x, n, randomSource<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array}</span></h4>

    



<div class="description">
    <p>从给定的包含 <code>n</code> 个元素的数组中创建一个<a href="http://en.wikipedia.org/wiki/Simple_random_sample">简单随机样本</a>。</p>
<p>采样值可以是任意顺序，不一定与输入中的顺序相同。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sample.js.html">sample.js</a>, <a href="sample.js.html#line17">line 17</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;any></code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>输入数组，可以包含任何类型</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>n</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>需要采样的元素数量</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>randomSource</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>function</code></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    Math.random
                
                </td>
            

            <td class="description last">
                <p>一个可选的熵源，返回 [0, 1) 范围内的数字</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>原始数组中的 <code>n</code> 个元素的子集</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>var values = [1, 2, 4, 5, 6, 7, 8, 9];
sample(values, 3); // 返回 3 个随机值，例如 [2, 5, 8];</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sampleCorrelation"><span class="type-signature"></span>sampleCorrelation<span class="signature">(x, y)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Correlation_and_dependence">相关系数</a>是衡量两个数据集相关性的指标，取值范围在-1到1之间</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sample_correlation.js.html">sample_correlation.js</a>, <a href="sample_correlation.js.html#line14">line 14</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第一个输入数据集</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>y</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第二个输入数据集</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>样本相关系数</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>sampleCorrelation([1, 2, 3, 4, 5, 6], [2, 2, 3, 4, 5, 60]).toFixed(2);
// => '0.69'</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sampleCovariance"><span class="type-signature"></span>sampleCovariance<span class="signature">(x, y)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Sample_mean_and_covariance">样本协方差</a>计算两个数据集的协同变化程度：
评估两个数据集的变动趋势是否一致。
x 和 y 是两个数据集，表示为数值数组。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sample_covariance.js.html">sample_covariance.js</a>, <a href="sample_covariance.js.html#line16">line 16</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>至少包含两个数据点的样本数据</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>y</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>至少包含两个数据点的样本数据</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>
<ul>
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>如果 x 和 y 的长度不相等</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    
        <li>

<dl>
    <dt>
        <div class="param-desc">
        <p>如果 x 或 y 的长度小于 2</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>

</li>
    </ul>
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>样本协方差</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>sampleCovariance([1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]); // => -3.5</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sampleKurtosis"><span class="type-signature"></span>sampleKurtosis<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Kurtosis">峰度</a> 是
衡量分布尾部相对于其方差的厚度的指标。峰度值可以是正数、负数，甚至未定义。</p>
<p>实现基于 Fisher 的超额峰度定义，并使用无偏矩估计。这是 Excel 中使用的版本，
并在多个统计软件包中可用，包括 SAS 和 SciPy。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sample_kurtosis.js.html">sample_kurtosis.js</a>, <a href="sample_kurtosis.js.html#line16">line 16</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含 4 个或更多数据点的样本</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果 x 的长度小于 4</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>样本峰度</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>sampleKurtosis([1, 2, 2, 3, 5]); // => 1.4555765595463122</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sampleRankCorrelation"><span class="type-signature"></span>sampleRankCorrelation<span class="signature">(x, y)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Rank_correlation">秩相关系数</a>是
衡量两个数组之间单调关系强度的指标</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sample_rank_correlation.js.html">sample_rank_correlation.js</a>, <a href="sample_rank_correlation.js.html#line11">line 11</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第一个输入数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>y</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第二个输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>样本秩相关系数</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sampleSkewness"><span class="type-signature"></span>sampleSkewness<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Skewness">偏度</a> 是衡量实值随机变量的概率分布
在均值一侧“倾斜”程度的统计量。
偏度的值可以为正、负，甚至未定义。</p>
<p>该实现基于调整后的 Fisher-Pearson 标准化矩系数，
该方法被 Excel 及多个统计软件（如 Minitab、SAS 和 SPSS）采用。</p>
</div>





<dl class="details">

    

    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>4.1.0</li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sample_skewness.js.html">sample_skewness.js</a>, <a href="sample_skewness.js.html#line18">line 18</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>至少包含 3 个数据点的样本数据</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果 x 的长度小于 3</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>样本偏度</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>sampleSkewness([2, 4, 6, 3, 1]); // => 0.590128656384365</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sampleStandardDeviation"><span class="type-signature"></span>sampleStandardDeviation<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Standard_deviation#Sample_standard_deviation">样本标准差</a>
是样本方差的平方根。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sample_standard_deviation.js.html">sample_standard_deviation.js</a>, <a href="sample_standard_deviation.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>样本标准差</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>sampleStandardDeviation([2, 4, 4, 4, 5, 5, 7, 9]).toFixed(2);
// => '2.14'</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sampleVariance"><span class="type-signature"></span>sampleVariance<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Variance#Sample_variance">样本方差</a>
是各数据点与均值偏离程度的平方和。样本方差通过<a href="https://en.wikipedia.org/wiki/Bessel's_correction">贝塞尔校正</a>
与普通方差区分：不使用输入数据长度直接除平方和，而是采用长度减一作为除数。
该方法可修正从未知完整性的数据集中进行估计时产生的偏差。</p>
<p>参考文献:</p>
<ul>
<li><a href="http://mathworld.wolfram.com/SampleVariance.html">Wolfram MathWorld 样本方差解释</a></li>
</ul>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sample_variance.js.html">sample_variance.js</a>, <a href="sample_variance.js.html#line18">line 18</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含两个及以上数据点的样本集</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>当输入数据长度小于2时抛出异常</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>样本方差值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>sampleVariance([1, 2, 3, 4, 5]); // => 2.5</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sampleWithReplacement"><span class="type-signature"></span>sampleWithReplacement<span class="signature">(x, n, randomSource<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array}</span></h4>

    



<div class="description">
    <p>有放回抽样是一种允许从总体中多次抽取同一项目的抽样方法。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sample_with_replacement.js.html">sample_with_replacement.js</a>, <a href="sample_with_replacement.js.html#line12">line 12</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;*></code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>任意类型的数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>n</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>需要抽取的元素数量</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>randomSource</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>function</code></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    Math.random
                
                </td>
            

            <td class="description last">
                <p>一个可选的熵源，返回介于0（包含）和1（不包含）之间的数字：[0, 1)</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>从总体中抽取的n个样本</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>var values = [1, 2, 3, 4];
sampleWithReplacement(values, 2); // 返回2个随机值，例如 [2, 4];</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="shuffle"><span class="type-signature"></span>shuffle<span class="signature">(x, randomSource<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">Fisher-Yates shuffle</a> 是一种快速生成有限集合随机排列的方法。
这是一个围绕 <code>shuffle_in_place</code> 的函数，保证不会修改输入。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="shuffle.js.html">shuffle.js</a>, <a href="shuffle.js.html#line14">line 14</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array</code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>包含0个或多个数字的样本</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>randomSource</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>function</code></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    Math.random
                
                </td>
            

            <td class="description last">
                <p>一个可选的熵源，返回范围在 [0, 1) 之间的数字</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>输入数组的随机排列版本</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>var shuffled = shuffle([1, 2, 3, 4]);
shuffled; // = [2, 3, 1, 4] 或其他随机排列</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="shuffleInPlace"><span class="type-signature"></span>shuffleInPlace<span class="signature">(x, randomSource<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle">费舍尔-耶茨洗牌算法</a>
原地洗牌实现（直接修改原始数组顺序）</p>
<p>该算法用于生成集合的随机<a href="https://en.wikipedia.org/wiki/Permutation">排列</a>。
注意：此方法会通过引用直接修改原始数组顺序。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="shuffle_in_place.js.html">shuffle_in_place.js</a>, <a href="shuffle_in_place.js.html#line16">line 16</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array</code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>包含一个或多个数值的样本集</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>randomSource</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>function</code></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    Math.random
                
                </td>
            

            <td class="description last">
                <p>可选随机数源，需返回[0,1)区间的数值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>原数组x（已洗牌）</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>var x = [1, 2, 3, 4];
shuffleInPlace(x);
// x将被洗牌为类似[2, 1, 4, 3]的随机排列</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sign"><span class="type-signature">(private) </span>sign<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="https://en.wikipedia.org/wiki/Sign_function">Sign</a> 是一个函数，
用于提取实数的符号</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sign.js.html">sign.js</a>, <a href="sign.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果输入参数 x 不是数字</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>TypeError</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>符号值，可能是 1、0 或 -1</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>sign(2); // => 1</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="silhouette"><span class="type-signature"></span>silhouette<span class="signature">(points, labels)</span><span class="type-signature"> &rarr; {Array.&lt;number>}</span></h4>

    



<div class="description">
    <p>计算聚类数据的<a href="https://en.wikipedia.org/wiki/Silhouette_(clustering)">轮廓系数</a></p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="silhouette.js.html">silhouette.js</a>, <a href="silhouette.js.html#line16">line 16</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>points</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>N维数据点的坐标数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>labels</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>数据点标签数组，长度必须与points一致，
且取值范围为[0..G-1]，其中G为分组总数</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>Array.&lt;number></code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>各数据点的轮廓系数值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>silhouette([[0.25], [0.75]], [0, 0]); // => [1.0, 1.0]</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="silhouetteMetric"><span class="type-signature"></span>silhouetteMetric<span class="signature">(points, labels)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>计算一组N维点的<a href="https://en.wikipedia.org/wiki/Silhouette_(clustering)">轮廓系数</a>。
该指标是数据中最大的单个轮廓值。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="silhouette_metric.js.html">silhouette_metric.js</a>, <a href="silhouette_metric.js.html#line16">line 16</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>points</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>N维点的坐标。</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>labels</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>点的标签。其长度必须与<code>points</code>相同，
并且值必须在[0..G-1]范围内，其中G是组的数量。</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>分组的轮廓系数。</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>silhouetteMetric([[0.25], [0.75]], [0, 0]); // => 1.0</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="ssq"><span class="type-signature">(private) </span>ssq<span class="signature">(j, i, sums, sumsOfSquares)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>基于数据数组的累积和及平方累积和，生成增量计算值</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="ckmeans.js.html">ckmeans.js</a>, <a href="ckmeans.js.html#line17">line 17</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>j</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>起始索引</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>i</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>结束索引</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>sums</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>累积和数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>sumsOfSquares</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>平方累积和数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>计算得到的平方偏差值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>ssq(0, 1, [-1, 0, 2], [1, 1, 5]);</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="standardDeviation"><span class="type-signature"></span>standardDeviation<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Standard_deviation">标准差</a>
是方差的平方根。这也被称为总体标准差。它用于衡量一组值中的变异或离散程度。</p>
<p>标准差仅适用于全总体数据：对于样本数据，使用 <a href="global.html#sampleStandardDeviation"><code>sampleStandardDeviation</code></a> 更为合适。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="standard_deviation.js.html">standard_deviation.js</a>, <a href="standard_deviation.js.html#line15">line 15</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>标准差</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>variance([2, 4, 4, 4, 5, 5, 7, 9]); // => 4
standardDeviation([2, 4, 4, 4, 5, 5, 7, 9]); // => 2</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="subtractFromMean"><span class="type-signature"></span>subtractFromMean<span class="signature">(mean, n, value)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>当从列表中移除一个值时，不必线性地重新计算列表的均值。相反，可以通过提供当前均值、
列表中的元素数量以及要移除的值，使用此函数来计算新的均值。</p>
</div>





<dl class="details">

    

    
    <dt class="tag-since">Since:</dt>
    <dd class="tag-since"><ul class="dummy"><li>3.0.0</li></ul></dd>
    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="subtract_from_mean.js.html">subtract_from_mean.js</a>, <a href="subtract_from_mean.js.html#line14">line 14</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>mean</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>当前均值</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>n</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>列表中的元素数量</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>value</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>要移除的值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>新的均值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>subtractFromMean(20.5, 6, 53); // => 14</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sum"><span class="type-signature"></span>sum<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>我们的默认求和算法是 <a href="https://pdfs.semanticscholar.org/1760/7d467cda1d0277ad272deb2113533131dc09.pdf">Kahan-Babuska算法</a>。
该算法是对经典的 <a href="https://en.wikipedia.org/wiki/Kahan_summation_algorithm">Kahan求和算法</a> 的改进。
它旨在计算一组数字的总和，同时纠正浮点误差。传统上，求和是通过多次连续的加法运算来完成的，每次加法都会产生自己的浮点舍入误差。
随着数字数量的增加，这些精度损失会累积。该替代算法比简单的加法求和更精确。</p>
<p>该算法的时间复杂度为 <code>O(n)</code>，即线性时间，与数组的长度成正比。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sum.js.html">sum.js</a>, <a href="sum.js.html#line14">line 14</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>所有输入数字的总和</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>sum([1, 2, 3]); // => 6</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sumNthPowerDeviations"><span class="type-signature"></span>sumNthPowerDeviations<span class="signature">(x, n)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>计算N次方偏差之和
当n=2时为平方偏差之和
当n=3时为立方偏差之和</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sum_nth_power_deviations.js.html">sum_nth_power_deviations.js</a>, <a href="sum_nth_power_deviations.js.html#line17">line 17</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>数据数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>n</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>次方数</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>N次方偏差之和</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>var input = [1, 2, 3];
// 由于数据集的方差是均方偏差，可以通过sumNthPowerDeviations计算：
sumNthPowerDeviations(input, 2) / input.length;</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="sumSimple"><span class="type-signature"></span>sumSimple<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>简单的<a href="https://en.wikipedia.org/wiki/Summation">求和</a>操作，
即将数组中的所有数字相加，从零开始。</p>
<p>该算法的时间复杂度为 <code>O(n)</code>，即线性时间，与数组的长度成正比。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="sum_simple.js.html">sum_simple.js</a>, <a href="sum_simple.js.html#line12">line 12</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>输入数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>所有输入数字的和</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>sumSimple([1, 2, 3]); // => 6</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="tTest"><span class="type-signature"></span>tTest<span class="signature">(x, expectedValue)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>用于计算<a href="https://en.wikipedia.org/wiki/Student%27s_t-test#One-sample_t-test">单样本t检验</a>，将样本均值与已知值x进行比较。</p>
<p>在这种情况下，我们试图确定总体均值是否等于我们已知的值，即这里的<code>x</code>。
通常，这里的结果用于查找<a href="http://en.wikipedia.org/wiki/P-value">p值</a>，对于一定的显著性水平，
可以确定是否拒绝原假设。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="t_test.js.html">t_test.js</a>, <a href="t_test.js.html#line17">line 17</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>一个或多个数字的样本</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>expectedValue</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>总体均值的期望值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>t值</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>tTest([1, 2, 3, 4, 5, 6], 3.385).toFixed(2); // => '0.16'</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="tTestTwoSample"><span class="type-signature"></span>tTestTwoSample<span class="signature">(sampleX, sampleY, difference<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {number|null}</span></h4>

    



<div class="description">
    <p>本函数用于计算<a href="http://en.wikipedia.org/wiki/Student's_t-test">双样本t检验</a>
检验&quot;mean(X)-mean(Y) = difference&quot;的假设（最常见情况是当<code>difference == 0</code>时，
检验两个样本是否可能来自具有相同均值的总体），在未知两样本标准差但假设它们具有相同标准差时使用。</p>
<p>通常计算结果用于查找<a href="http://en.wikipedia.org/wiki/P-value">P值</a>，
根据给定的显著性水平判断是否可以拒绝零假设。</p>
<p>当差值为0时，<code>diff</code>参数可省略。</p>
<p><a href="https://en.wikipedia.org/wiki/Exclusion_of_the_null_hypothesis">本检验用于拒绝</a>
样本X和样本Y来自相同总体均值的零假设。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="t_test_two_sample.js.html">t_test_two_sample.js</a>, <a href="t_test_two_sample.js.html#line25">line 25</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        
        <th>Default</th>
        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>sampleX</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>样本数据，以数字数组表示</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>sampleY</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            
                <td class="default">
                
                </td>
            

            <td class="description last">
                <p>样本数据，以数字数组表示</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>difference</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            
                <td class="default">
                
                    0
                
                </td>
            

            <td class="description last">
                <p>期望均值差</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>
|

<span class="param-type"><code>null</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>检验统计量</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>tTestTwoSample([1, 2, 3, 4], [3, 4, 5, 6], 0); // => -2.1908902300206643</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="uniqueCountSorted"><span class="type-signature"></span>uniqueCountSorted<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>对于一个已排序的输入，计算唯一值的数量可以在常数时间和常数内存内完成。
这是该算法的一个简单实现。</p>
<p>值使用 <code>===</code> 进行比较，因此对象和非原始对象不会以任何特殊方式处理。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="unique_count_sorted.js.html">unique_count_sorted.js</a>, <a href="unique_count_sorted.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;*></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>包含任意类型值的数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>唯一值的数量</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>uniqueCountSorted([1, 2, 3]); // => 3
uniqueCountSorted([1, 1, 1]); // => 1</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="upperBound"><span class="type-signature"></span>upperBound<span class="signature">(x, value)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>二分查找上界索引（第一个大于目标值的位置）</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="quantile_rank_sorted.js.html">quantile_rank_sorted.js</a>, <a href="quantile_rank_sorted.js.html#line87">line 87</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>已排序数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>value</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>目标值</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>上界索引</p>
</div>

    
</div>



</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="variance"><span class="type-signature"></span>variance<span class="signature">(x)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Variance">方差</a>
是数据点与均值之间偏差的平方和。</p>
<p>这是方差的实现，不是样本方差：
如果你需要一个样本度量，请使用 <code>sampleVariance</code> 方法。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="variance.js.html">variance.js</a>, <a href="variance.js.html#line17">line 17</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>一个包含一个或多个数据点的总体</p>
                
            </td>
        </tr>

    
    </tbody>
</table>












<div class="section-throws">
<h5>Throws:</h5>

        

<dl>
    <dt>
        <div class="param-desc">
        <p>如果 x 的长度为 0</p>
        </div>
    </dt>
    <dd></dd>
    <dt>
        <dl>
            <dt>
                Type
            </dt>
            <dd>
                
<span class="param-type"><code>Error</code></span>


            </dd>
        </dl>
    </dt>
    <dd></dd>
</dl>


    
</div>



<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>方差：一个大于或等于零的值。
零表示所有值都相同。</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>variance([1, 2, 3, 4, 5, 6]); // => 2.9166666666666665</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="wilcoxonRankSum"><span class="type-signature"></span>wilcoxonRankSum<span class="signature">(sampleX, sampleY)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p>本函数计算第一个样本相对于第二个样本的<a href="https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test">威尔科克森秩和统计量</a>。
该检验是t检验的非参数替代方法，等价于曼-惠特尼U检验。计算过程包含以下步骤：</p>
<ol>
<li>合并两个样本并进行排序</li>
<li>处理相同观测值的并列秩次</li>
<li>计算指定样本的秩和</li>
</ol>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="wilcoxon_rank_sum.js.html">wilcoxon_rank_sum.js</a>, <a href="wilcoxon_rank_sum.js.html#line14">line 14</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>sampleX</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第一个样本数值数组</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>sampleY</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last">
                <p>第二个样本数值数组</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>样本X的秩和统计量</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>wilcoxonRankSum([1, 4, 8], [9, 12, 15]); // => 6</code></pre>

</div>

</div>
        
            
<div class="section-method">

    

    <h4 class="name" id="zScore"><span class="type-signature"></span>zScore<span class="signature">(x, mean, standardDeviation)</span><span class="type-signature"> &rarr; {number}</span></h4>

    



<div class="description">
    <p><a href="http://en.wikipedia.org/wiki/Standard_score">Z分数（标准分数）</a>计算函数。</p>
<p>标准分数表示观测值与均值的偏离程度，以标准差为单位计量。正值表示高于均值，
负值表示低于均值。其计算方式为：原始分数减去总体均值，再除以总体标准差，
结果为无量纲量。</p>
<p>注意：Z分数的计算需要已知总体参数（μ和σ）；若仅有样本数据，
使用样本均值和样本标准差计算将得到学生t统计量。</p>
</div>





<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="z_score.js.html">z_score.js</a>, <a href="z_score.js.html#line18">line 18</a>
    </li></ul></dd>
    

    

    

    
</dl>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>x</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>观测值</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>mean</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>总体均值</p>
                
            </td>
        </tr>

    

        <tr>
            
                <td class="name"><code>standardDeviation</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>number</code></span>


            
            </td>

            

            

            <td class="description last">
                <p>总体标准差</p>
                
            </td>
        </tr>

    
    </tbody>
</table>














<div class="section-returns">
<h5>Returns:</h5>

        

<dl class="param-type">
    <dt>
        Type:
    </dt>
    <dd>
        
<span class="param-type"><code>number</code></span>


    </dd>
</dl>


<div class="param-desc">
    <p>Z分数</p>
</div>

    
</div>



<div class="section-examples">
<h5>Example</h5>

    <pre class="prettyprint"><code>zScore(78, 80, 5); // => -0.4</code></pre>

</div>

</div>
        
    

    
        <h3 class="subsection-title">Type Definitions</h3>

        
                
<div class="section-members">
<h4 class="name" id="kMeansReturn">kMeansReturn</h4>








    <h5 class="subsection-title">Properties:</h5>

    

<table class="props">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>labels</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;number></code></span>


            
            </td>

            

            

            <td class="description last"><p>数据点所属簇的标签数组</p></td>
        </tr>

        

    

        <tr>
            
                <td class="name"><code>centroids</code></td>
            

            <td class="type">
            
                
<span class="param-type"><code>Array.&lt;Array.&lt;number>></code></span>


            
            </td>

            

            

            <td class="description last"><p>聚类中心坐标数组</p></td>
        </tr>

        

    
    </tbody>
</table>




<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="k_means_cluster.js.html">k_means_cluster.js</a>, <a href="k_means_cluster.js.html#line5">line 5</a>
    </li></ul></dd>
    

    

    

    
</dl>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type"><code>Object</code></span>


        </li>
    </ul>





</div>

            
    

    
</article>

</section>




</div>

<br class="clear">

<footer>
    Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.4</a> on Wed Mar 19 2025 01:24:22 GMT+0800 (GMT+08:00) using the Minami theme.
</footer>

<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>